# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-06-16
# @File : 0_hook.py


import frida
import sys

rdev = frida.get_remote_device()
# Application(identifier="tv.danmaku.bili", name="哔哩哔哩", pid=20650, parameters={})
session = rdev.attach("Momo")

scr = """
Java.perform(function () {
    var a = Java.use("com.immomo.momo.protocol.http.a.a");
    a.addCommonFormData.implementation = function(map,z){
        var result = "";
        var keyset = map.keySet();
        var it = keyset.iterator();
        while(it.hasNext()){
            var keystr = it.next().toString();
            var valuestr = map.get(keystr).toString();
            result += valuestr;
        }
        console.log("——————————————————————请求来了——————————————————————");
        console.log("——————————————————————这是map",map);
        console.log("——————————————————————这是result",result);
        console.log("——————————————————————这是z",z);
        
        console.log(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Throwable").$new()));

    };


});
"""

script = session.create_script(scr)


def on_message(message, data):
    print(message, data)


script.on("message", on_message)

script.load()
sys.stdin.read()
